<template>
    <a-card :bordered="false">
        <div class="table-page-search-wrapper">
            <a-spin :spinning="spanLoading">
                <a-form layout="inline" :form="form">
                    <a-row :gutter="48">
                        <a-col :md="6" :sm="24">
                            <a-form-item label=券号>
                                <a-input placeholder="请输入券号"
                                    v-decorator="['voucherNo', {rules: [{ required: true, message: '请输入券号' }]}]" />
                            </a-form-item>
                        </a-col>
                        <a-col :md="6" :sm="24">
                            <a-form-item label="所退积分">
                                <a-input placeholder="请输入所退积分"
                                    v-decorator="['integral', {rules: [{ required: true, message: '请输入所退积分' }]}]" />
                            </a-form-item>
                        </a-col>
                        <a-col :md="6" :sm="24">
                            <span class="table-page-search-submitButtons">
                                <a-button type="primary" @click="showConfrim">提交</a-button>
                            </span>
                        </a-col>
                    </a-row>
                </a-form>
            </a-spin>
        </div>

    </a-card>
</template>

<script>
import { refundIntegral } from '@/api/operateTools/index'
export default {
    name: '',
    data() {
        return {
            form: this.$form.createForm(this),
            spanLoading: false
        }
    },
    components: {},
    methods: {
        showConfrim(e) {
            e.preventDefault()
            this.form.validateFields((err, values) => {
                if (!err) {
                    console.log('Received values of form: ', values)
                    this.$confirm({
                        title: "温馨提示",
                        content: `确定退${values.integral}积分？`,
                        onOk:()=> {
                            this.submit(values)
                        },
                        onCancel() { },
                    })
                }
            })

        },
        async submit(obj) {
            const res = await refundIntegral(obj)
            if (res.code == 200) {
                this.$message.success('成功')
            } else {
                this.$message.error(res.msg || res.message || '请求失败')
            }
        },
    }
}
</script>

<style scoped>

</style>
